package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Awardproject;
import com.hbnu.system.service.IAwardprojectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/awardproject")
@Api(tags = "成果关联项目模块")
public class AwardprojectController {
    @Autowired
    IAwardprojectService iAwardprojectService;
    @ApiOperation("成果关联项目添加")
    @PostMapping("/AddawardProject")
    public Rest<Boolean> AddawardProject(@RequestBody Awardproject awardproject){
        boolean add = iAwardprojectService.addAwardProject(awardproject);
        return add ? Rest.success() : Rest.failed();
    }
    @ApiOperation("成果关联项目删除")
    @GetMapping("/RemoveAwardProject")
    public Rest<Boolean> RemoveAwardProject(String id){
        boolean remove = iAwardprojectService.removeAwardProject(id);
        return remove ? Rest.success() : Rest.failed();
    }

    @ApiOperation("成果关联项目更新")
    @PostMapping("/UpdateAwardProject")
    public Rest<Boolean> UpdateAwardProject(@RequestBody Awardproject awardproject){
        boolean update = iAwardprojectService.updateAwardProject(awardproject);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("成果关联项目查询")
    @GetMapping("/GetAwardProjectByAwardID")
    public Rest<List<Awardproject>> GetAwardProjectByAwardID(String awardID){
        List<Awardproject> awardProjectByAwardID = iAwardprojectService.getAwardProjectByAwardID(awardID);
        return Rest.success(awardProjectByAwardID);
    }
}

